<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('非实物登记列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <input id="treeId" name="deptId" type="hidden"/>
                <input id="thingTypeId" name="thingTypeId" type="hidden"/>
                <div class="select-list">
                    <ul>
                        <li>
                            <label>行名称：</label>
                            <input readonly="readonly" onclick="selectDeptTree()" id="treeName" type="text"
                                   placeholder="请选择归属行">
                        </li>
                        <li>
                            <label>项目名称：</label>
                            <input type="text" name="createName"/>
                        </li>
                        <li>
                            <label>收支项目：</label>
                            <input readonly="readonly" onclick="selectThingTypeTree()" id="thingType" type="text"
                                   placeholder="请选择收支项目">
                        </li>
                        <li>
                            <label>发票号：</label>
                            <input type="text" name="lnvoiceNumber"/>
                        </li>
                        <li>
                            <label style="width: 100px">发票总金额：</label>
                            <input type="number" name="zonge"/>
                        </li>
                        <li>
                            <label style="width: 100px">销售单位名称：</label>
                            <input type="text" name="saleName"/>
                        </li>
                        <li class="select-time">
                            <label>支出时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="chongzhi()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="financial:enterXuni:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="financial:enterXuni:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="financial:enterXuni:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('financial:enterXuni:edit')}]];
    var removeFlag = [[${@permission.hasPermi('financial:enterXuni:remove')}]];
    var prefix = ctx + "financial/enterXuni";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "非实物登记",
            columns: [{
                checkbox: true
            },
                {
                    field: 'xuniId',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'deptName',
                    title: '行名称'
                },
                {
                    field: 'createName',
                    title: '项目名称'
                },
                {
                    field: 'thingType',
                    title: '收支项目'
                },

                {
                    field: 'lnvoiceNumber',
                    title: '发票号'
                },
                {
                    field: 'zonge',
                    title: '发票总金额'
                },
                {
                    field: 'saleName',
                    title: '销售单位名称'
                },
                {
                    field: 'createBy',
                    title: '登记人'
                },
                {
                    field: 'enterTime',
                    title: '支出时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.xuniId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.xuniId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function selectDeptTree() {
        var treeId = $("#treeId").val();
        var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
        var url = ctx + "system/user/selectDeptTree/" + deptId;
        var options = {
            title: '选择行',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero) {
        var body = $.modal.getChildFrame(index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        $.modal.close(index);
    }

    function selectThingTypeTree() {
        var treeId = $("#categoryTreeId").val();
        var url = ctx + "financial/thingType/selectThingTypeTree/";
        var options = {
            title: '选择收支项目',
            width: "380",
            url: url,
            callBack: doSubmit3
        };
        $.modal.openOptions(options);
    }

    function doSubmit3(index, layero) {
        var body = $.modal.getChildFrame(index);
        $("#thingTypeId").val(body.find('#treeId').val());
        $("#thingType").val(body.find('#treeName').val());
        $.modal.close(index);
    }

    function chongzhi() {
        $("#treeId").val("")
        $("#thingTypeId").val("")
        $.form.reset()
    }

</script>
</body>
</html>